const VClickOutside = {
  name: 'click-outside',
  beforeMount: (el, binding) => {
    el.clickHandler = (e) => {
      if (!(el === e.target || el.contains(e.target))) {
        binding.value()
      }
    }
    document.addEventListener('click', el.clickHandler)
  },
  unmounted(el) {
    document.removeEventListener(el, el.clickHandler)
  },
}
export default VClickOutside
